#include <bits/stdc++.h>
using namespace std;
const int N=1e5+7;
vector<int> G[N];
int k[N], u[N], ans;
void dfs(int x)
{
    for(int y:G[x]){
        dfs(y);
        u[x] = max(u[x], u[y]-1);
        k[x] = max(k[x], k[y]-1);
    }
    if(!u[x]){
        ++ans;
        u[x] = k[x];
    }
}


int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int n; cin >> n;
    for (int i = 2; i <=n; ++i) {
        int f; cin >> f;
        G[f].push_back(i);
    }
    for (int i = 1; i <= n ; ++i) cin>>k[i];
    dfs(1);
    cout<<ans<<endl;
    return 0;
}